package com.core.dto;

import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 2016-01-13
 * Time: 14:32
 * To change this template use Editor | File and Code Templates.
 */
public class PageDTO {

    public static int pageSize = 8;
    private String currentPage;
    private String totalPage;

    public PageDTO() {
    }

    public static int getPageSize() {
        return pageSize;
    }

    public static void setPageSize(int pageSize) {
        PageDTO.pageSize = pageSize;
    }

    public String getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(String currentPage) {
        this.currentPage = currentPage;
    }

    public String getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(String totalPage) {
        this.totalPage = totalPage;
    }

    public static String isPage(String page, String maxPage) {
        boolean f = Pattern.matches("[1-9][0-9]*", page);
        if (f == false) {
            return "1";
        }
        if (Integer.parseInt(page) >= Integer.parseInt(maxPage)) {
            return maxPage;
        }
        return page;
    }
}
